﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using Spire.DataExport;


namespace Spire.DataExport.Sample
{
    class Class1
    {
        public void main()
        {
             OleDbConnection connection = new OleDbConnection();
            connection.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Database Password=;Data Source="".\..\database\demo.mdb"";Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False";
            OleDbCommand command = new OleDbCommand();
            command.CommandText = "select * from parts";
            command.Connection = connection;  
            //Xls export
            Spire.DataExport.XLS.CellExport cellExport1  = new Spire.DataExport.XLS.CellExport();
            cellExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            cellExport1.FileName = "sample.xls";
            cellExport1.SQLCommand = command;
            cellExport1.SaveToFile();
            //PDF export
            Spire.DataExport.PDF.PDFExport pdfExport1 = new Spire.DataExport.PDF.PDFExport();
            pdfExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            pdfExport1.FileName = "sample.pdf";
            pdfExport1.SQLCommand = command;
            pdfExport1.SaveToFile();
            //Html export
            Spire.DataExport.HTML.HTMLExport htmlExport1 = new Spire.DataExport.HTML.HTMLExport();
            htmlExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            htmlExport1.FileName = "sample.html";
            htmlExport1.SQLCommand = command;
            htmlExport1.SaveToFile();
            //xml export
            Spire.DataExport.XML.XMLExport xmlExport1 = new Spire.DataExport.XML.XMLExport();
            xmlExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            xmlExport1.FileName = "sample.xml";
            htmlExport1.SQLCommand = command;
            htmlExport1.SaveToFile();
            //Rtf export
            Spire.DataExport.RTF.RTFExport rtfExport1 = new Spire.DataExport.RTF.RTFExport();
            rtfExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            pdfExport1.FileName = "sample.rtf";
            pdfExport1.SQLCommand = command;
            pdfExport1.SaveToFile();
            //clipboard export
            Spire.DataExport.Clipboard.ClipboardExport clipboardExport1 = new Clipboard.ClipboardExport();
            clipboardExport1.SQLCommand = command;
            clipboardExport1.ShowContent = true;
            clipboardExport1.SaveToFile();
            //Access export
            Spire.DataExport.Access.AccessExport accessExport1 = new Access.AccessExport();
            accessExport1.DatabaseName = "test.mdb";
            accessExport1.TableName = "ExportData";
            accessExport1.SQLCommand = command;
            //Sql export
            Spire.DataExport.SQL.SQLExport sqlExport1 = new Spire.DataExport.SQL.SQLExport();
            sqlExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            sqlExport1.CommitStatement = "COMMIT;";
            sqlExport1.FileName = "sample.sql";
            sqlExport1.SQLCommand = command;
            sqlExport1.TableName = "TestTable";
            sqlExport1.SaveToFile();
            //Dbf export
            Spire.DataExport.DBF.DBFExport dbfExport1 = new Spire.DataExport.DBF.DBFExport();
            dbfExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            dbfExport1.FileName = "sample.dbf";
            dbfExport1.SQLCommand = command;
            dbfExport1.SaveToFile();
            //Txt export
            Spire.DataExport.TXT.TXTExport txtExport1 = new Spire.DataExport.TXT.TXTExport();
            txtExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            pdfExport1.FileName = "sample.txt";
            pdfExport1.SQLCommand = command;
            pdfExport1.SaveToFile();
            //Sylk export      
            txtExport1.ExportType =Spire.DataExport.TXT.TextExportType.SYLK;
            txtExport1.FileName = "sample.slk";
            txtExport1.SaveToFile();
            //Csv export
            txtExport1.ExportType = Spire.DataExport.TXT.TextExportType.CSV;
            txtExport1.FileName = "sample.csv";
            txtExport1.SaveToFile();
            //Dif export
            txtExport1.ExportType = Spire.DataExport.TXT.TextExportType.DIF;
            txtExport1.FileName = "sample.dif";
            txtExport1.SaveToFile();

        }
    }
}
